home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir30
/
eeremw11.zip
/
EEREM.DOC
< prev
next >
Wrap
Text File
|
1994-08-09
|
16KB
|
416 lines
Documentation for Extra Entity REMoval version 1.0 August 7, 1994
Jon Fleming CIS 70334,2443
WHAT IS EEREM?
EEREM is a package written in C for the AutoCAD ADS environment.
It removes a large set of possible "extra entities" from an AutoCAD
drawing. An "extra entity" is one which adds no information to the
drawing, such as duplicate lines. Extra entities can arise from many
situations. One situation that can give rise to MANY extra entities
is projecting a 3D wireframe model into 2D with PROJECT.LSP (included
with AutoCAD) or the equivalent.
Extra entities are inconvenient because they increase drawing file
size, lead to unexpected OSNAP results, and cause clogging of pens in
pen plotters forced to trace the same path several times.
BOILERPLATE
EEREM is public domain. You may do what you want with it; please
credit me if you use the code or any significant portion of it in
your programs.
I expect EEREM to do what it is described as doing. However,
EEREM is supplied "as-is" with no warranty of mercantability or
fitness for a particular purpose. I accept no responsibility for its
operation or damages of any kind.
If you bring problems to my attention, I will do what I can to
resolve them.
WHAT DO I NEED TO USE EEREM?
This incarnation of EEREM has been tested under AutoCAD Release
12 c3 DOS and AutoCAD Release 12 c4 Windows. It may run under higher
release numbers, I cannot determine that at this time. If
appropriately compiled, it _should_ run on other platforms.
For some reason I don't understand, EEREM does not work as well
on polylines under Windows as it does under DOS.
EEREM will NOT work under AutoCAD Release 11 or previous.
WARNING: Although I cannot prove it, I think that earlier
releases of AutoCAD 12 had bugs in the ads_ssget() "X" interface which
led to EEREM missing many entities it should delete. If EEREM does
not do the job for you, and you are running an older release of R12,
upgrade to the current release.
HOW DO I USE EEREM?
First, copy EEREM.EXP and EEREM.DCL into a directory (or
directories) that is (are) listed in the AutoCAD "ACAD" environment
variable.
EEREM must be loaded into memory. At the AutoCAD "Command:"
prompt, you may type:
(xload "eerem")
(note: once you have loaded EEREM, you need not do it again until you
have exited and re-entered AutoCAD. This is different from LISP
programs which you must load every time you move from one drawing to
another without exiting AutoCAD).
Once EEREM is loaded, at the AutoCAD "Command:" prompt, type:
ddeerem
Then click on the "Select Entities for Checking" button, select a set
of entities to check, and click on the OK button.
See "ADVANCED EEREM USAGE", below, for hints and suggestions on
how to use EEREM efficiently; explanations of the other items in the
dialog box; and using EEREM from your own AutoLISP or C program.
WHAT ENTITIES DOES EEREM REMOVE?
First, a pair of definitions:
duplicate entity = an entity that covers EXACTLY the same extents as
another entity.
underlying entity = an entity that DOES NOT cover exactly the same
extents as another entity but is completely
covered by that other entity.
For example, if there's a line from (0,0,0) to (1,0,0), then another
line from (0,0,0) to (1,0,0) is a DUPLICATE entity. Lines from (for
example) (0,0,0) to (0,0,0) or from (0.25,0,0) to (0.75,0,0) are
UNDERLYING entities.
Briefly (see "DETAILED ENTITY REMOVAL SPECIFICATIONS", below, for
more detail), EEREM removes:
All line duplicates and lines that underlie other lines (including
"zero-length" lines if they underlie a non-zero-length line).
All circle duplicates and arcs that underlie circles (circles
underlying circles are duplicate circles!).
All arc duplicates and arcs that underlie arcs.
All duplicate points (points underlying points are the same as
duplicate points!)
Most 2D and 3D (but not mesh) polyline duplicates and most 2D and 3D
(but not mesh) polylines that underlie other 2D and 3D (but not
mesh) polylines
WHAT COMMON EXTRA ENTITIES ARE _NOT_ REMOVED?
Different-type entities, such as polylines underlying lines.
(such entities are often created by PROJECT.LSP; all versions that
I've examined project all circles and arcs as polylines even when a
line or arc or circle would be more appropriate. I haven't examined
the Release 12 PROJECT.LSP).
Entities that appear to overlay each other on the screen but are
actually far enough apart for EEREM to consider them different.
Entities that overlap, but neither entity completely covers the
other.
HINTS
EEREM will run _much_ more slowly if there are a lot of entities
in the drawing that are not involved in EEREM's operation. This is
because EEREM asks AutoCAD to search the entire drawing database for
entities that may be deleted, and does so many times. (Other
algorithms that I thought of proved to be much slower in 99% of the
cases).
Always run EEREM in a drawing that contains as few entities as
possible. The AutoCAD WBLOCK command is often useful for creating
temporary drawings on which to run EEREM.
ADVANCED EEREM USAGE: EASY LOADING
AutoCAD Release 12 includes a sophisticated automatic loading
facility for command-line-callable functions. To activate this, if
you DO NOT have an S::STARTUP function in ACAD.LSP, add the following
to ACAD.LSP:
(defun S::STARTUP ()
(autoxload "EEREM" '("DDEEREM"))
)
If you already have a S::STARTUP function in ACAD.LSP, add the
following to it:
(autoxload "EEREM" '("DDEEREM"))
For usage from AutoLISP, the following works:
(if eerem
(eerem sel_set)
(if (xload "EEREM")
(eerem sel_set)
(prompt "\nCan't locate EEREM.EXP!")
)
)
ADVANCED EEREM USAGE: FROM THE "COMMAND:" PROMPT
I hope the three check boxes at the top of the dialog box are
self-explanatory. For example, say there's a line from (0,0,0) to
(1,0,0) on layer "0", and another line from (0,0,0) to (1,0,0) on
layer "DUMMY". If the "Entities on different layers are different"
check box IS NOT checked, EEREM will remove one of these entites
(which one depends on their order in the set of entities selected for
checking). If the "Entities on different layers are different" check
box IS checked, EEREM will not remove either entity. The other two
check boxes behave in an analogous fashion.
There is one aspect that may be counterintuitive. The colors or
linetypes BYLAYER or BYBLOCK are always considered different from an
explicit color or linetype. For example, say there are two lines that
are identical in every respect, including what layer they are on,
except one has color BYLAYER and one has color YELLOW. Say also that
the default color of the layer is YELLOW. The two lines appear
identical on screen, but if the "Entities with different colors are
different" checkbox is checked EEREM will _not_ remove either line.
You probably don't want to change the "Tolerance" value, but you
can try it if you want. Briefly, the tolerance is a measure of how
far apart points must be before EEREM considers them unequal (see
"DETAILED ENTITY REMOVAL SPECIFICATIONS", below, for more
explanation). The tolerance is in drawing units.
ADVANCED EEREM USAGE: FROM AUTOLISP
The dialog box version of EEREM may be called from AutoLISP by:
(ddeerem)
There is no return value.
To call the EEREM core engine without putting up a dialog box,
use:
(eerem sel_set checklayer checkltype checkcolor tolerance)
where:
sel_set is a selection set of entities to check, and is required.
checklayer is NIL to count entities on different layers as the same,
non-NIL to count entities on different layers as different. checklayer
is optional (default NIL) unless one or more of the following arguments
are supplied.
checkltype is NIL to count entities with different linetypes as the
same, non-NIL to count entities with different linetypes as different.
checkltype is optional (default NIL) unless one or more of the
following arguments are supplied.
checkcolor is NIL to count entities with different colors as the same,
non-NIL to count entities with different colors as different.
checkcolor is optional (default NIL) unless one or more of the
following arguments are supplied.
tolerance is a real number that measures how close points must be to
be considered the same (well, approximately; see "DETAILED ENTITY
REMOVAL SPECIFICATIONS", below, for more detail). tolerance is
optional. The default is 0.00001.
(eerem ...) returns NIL if an error was detected or T otherwise.
ADVANCED EEREM USAGE: FROM ADS
Call ddeerem through ads_invoke(). The return values are RSRSLT
(no error detected) or RSERR (can't find DCL file).
Call eerem through ads_invoke() with a list corresponding to the
AutoLISP parameters. The return values are RSRSLT (corresponding to
the AutOLISP "T" return values, above) or RSERR (corresponding to the
AutoLISP "NIL" return values, above).
I haven't tested this.
DETAILED ENTITY REMOVAL SPECIFICATIONS: GENERAL
All entity removal is based on a "current" entity and a
"candidate" entity. The current entity is one of the set of entities
that was selected for extra entity removal, and must be a LINE,
non-mesh POLYLINE, CIRCLE, ARC, or POINT. Other entity types, in the
set of entities selected for extra entity removal, are skipped. The
candidate is the same type of entity as the current entity but MAY OR
MAY NOT be in the set of entities selected for extra entity removal;
all possible candidates in the drawing are checked. The candidate is
the entity which will be deleted if it meets the criteria listed in
the following sections.
All combinations of current and candidate entities are checked.
Most of the filtering of candidate entities is done through the
ads_ssget() "X" mechanism, yielding a (usually) small set of
candidate entities that require further checking. I think it is a
failure of the ads_ssget "X" mechanism to return the proper set of
entities that makes EEREM work improperly in early versions of R12
when the viewpoint is not "plan UCS".
Note that entity thickness IS NEVER CHECKED; if two entities are
the same except for thickness, one of them will be removed!
The following sections do not discuss whether or not the current
and candidate entity's layer, color, or linetype matter. If the
appropriate flag(s) is(are) set, through the dialog box or through a
parameter to the function, unsuitable candidates are filtered out by
ads_ssget() "X".
DETAILED ENTITY REMOVAL SPECIFICATIONS: LINES
The candidate line is deleted if both its endpoints lie within a
cylinder of radius "tolerance", centered on the current line and the
same length as the current line.
Lines shorter than 0.0001 times "tolerance" are not considered as
"current" entities, because the algorithm blows up for coincident
current line endpoints. The presumption is that such short (or even
zero-length) lines are extremely likely to be underlying some other
line.
DETAILED ENTITY REMOVAL SPECIFICATIONS: CIRCLES & UNDERLYING ARCS
When the current entity is a circle, a candidate circle or arc is
deleted if:
its center lies within a cube of side two times "tolerance", centered
on the center of the current circle
AND
the candidate's radius is within plus or minus "tolerance" of the
current circle's radius
AND
the distance from the tip of the candidate's extrusion vector to
EITHER the tip of the current circle's extrusion vector OR the tip of
a unit vector directly opposite the current circle's extrusion vector
is less than "tolerance".
DETAILED ENTITY REMOVAL SPECIFICATIONS: POINTS
A candidate point is deleted if it lies within a cube of side two
times "tolerance", centered on the current point entity.
DETAILED ENTITY REMOVAL SPECIFICATIONS: ARCS
When the current entity is an arc, a candidate arc is deleted if:
its center lies within a cube of side two times "tolerance", centered
on the center of the current arc
AND
the candidate's radius is within plus or minus "tolerance" of the
current arc's radius
AND
the start and end points of the candidate arc are on or between the
start and end points of the current arc
AND
the distance from the tip of the candidate's extrusion vector to
EITHER the tip of the current arc's extrusion vector OR the tip of
a unit vector directly opposite the current arc's extrusion vector
is less than "tolerance".
DETAILED ENTITY REMOVAL SPECIFICATIONS: POLYLINES
Both the current and candidate polylines may not be 3D polygon
meshes; such entities are skipped if they occur in the set of
entities to check.
Ready? This is the BIG ONE! Onward ...
A candidate polyline is deleted if:
its elevation is within plus or minus "tolerance" of the elevation of
the current polyline
AND
the candidate's start and end widths are within plus or minus
"tolerance" of the current polyline's start and end widths,
respectively
AND
the candidate's polyline type and curve fit type are the same as the
current polyline
AND
the distance from the tip of the candidate's extrusion vector to the
tip of the current polyline's extrusion vector is less than
"tolerance" (note that, unlike circles and arcs, polylines with
extrusion vectors exactly opposite to that of the current polyline
are not checked for deletion)
AND
for each successive vertex of the candidate, there is a vertex of the
current polyline that:
immediately follows the last current polyline vertex that matched
the previous candidate polyline vertex
AND
matches the current candidate polyline vertex.
In the above, "matches" means that:
the distance from the candidate vertex to the current polyline vertex
is less than "tolerance"
AND
the candidate vertex's start and end widths are within plus or minus
"tolerance" of the current polyline vertex's start and end widths,
respectively
AND
the candidate vertex's bulge factor is within plus or minus
"tolerance" of the current polyline vertex's bulge factor
AND
the distance from the tip of the candidate vertex's tangent vector to
the tip of the current polyline vertex's tangent vector is less than
"tolerance"
AND
the current vertex's flag bits (group 70) are the same as the flag
bits of the current polyline vertex.
(Whoof! That was almost as hard to write down precisely as it was to
figure out!)
COMPILING EEREM:
EEREM was compiled for DOS or Windows using Watcom C/C++-32 9.5.
A .MAK file is included (in the source code package) for Watcom WMAKE.
Hints: be careful when asking the compiler to do agressive
optimization; when I used "opmaxet" EEREM appeared to work but never
removed any polylines. Be sure to delete *>OBJ or TOUCH *.C when
changing from compiling for Windows to compiling for DOS or vice
versa.